package app.kotlin_1.utils

import android.app.Activity
import android.content.Context
import android.support.annotation.LayoutRes
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.Toast
import com.squareup.picasso.Picasso

/**
 * Created by 刘智强 on 2017/9/20.
 * 扩展函数
 */
fun Log.e(message: String?) {
    Log.e("Kotlin", message)

}
fun Activity.e(message: String?){
    Log.e("Kotlin", message)
}

fun  Context.e(message: String?){
    Log.e("Kotlin", message)
}

fun Activity.toast(meaasge: String?) {
    Toast.makeText(this, meaasge, Toast.LENGTH_LONG).show()
}

fun Context.toast(meaasge: String?) {
    Toast.makeText(this, meaasge, Toast.LENGTH_LONG).show()

}

fun ViewGroup.inflate(@LayoutRes layoutRes: Int, attachToRoot: Boolean = false): View {
    return LayoutInflater.from(context).inflate(layoutRes, this, attachToRoot)
}

fun ImageView.loadUrl(url: String) {
    Picasso.with(context).load(url).into(this)

}


